/**********************************************
** @Author: phy
** @Date:   2017-12-12 14:17:37
** @Last Modified by:   phy


CREATE TABLE `UserCtrlInfo` (
  `ID` int(10) NOT NULL AUTO_INCREMENT,
  `USERID` int(10) NOT NULL DEFAULT '0' COMMENT '用户ID',
  `NTYPE` int(10) NOT NULL DEFAULT '0' COMMENT '0-修改金币 1-修改作弊率 2-账号状态 3-修改用户类型(银商,普通用户)4-礼物找回 5-删除邮件 6-修改钻石 7-修改奖券 8-修改贵宾的推广号 9-修改密码 10-修改昵称 11-解绑手机 12-关联点控 13-修改个性签名 14-关联锁定',
  `GOLD` bigint(20) NOT NULL DEFAULT '0' COMMENT '背包金币',
  `CHEATRATE` int(20) NOT NULL DEFAULT '0' COMMENT '作弊率',
  `CHEATSCORE` int(20) NOT NULL DEFAULT '0' COMMENT '作弊分数',
  `STATUS` int(20) NOT NULL DEFAULT '0' COMMENT '账号状态 0-正常 1-禁止登陆',
  `LVSIGN` int(20) NOT NULL DEFAULT '0' COMMENT '作弊分数',
  `GiveGiftID` bigint(20) NOT NULL DEFAULT '0' COMMENT '礼物找回的邮件ID',
  `MailID` bigint(20) NOT NULL DEFAULT '0' COMMENT '要删除的邮件ID',
  `DIAMOND` bigint(20) NOT NULL DEFAULT '0' COMMENT '钻石',
  `TICKET` bigint(20) NOT NULL DEFAULT '0' COMMENT '奖券',
  `DESGAMEID` int(20) NOT NULL DEFAULT '0' COMMENT '要修改的靓号(推广号)',
  `CHANGEPASSWD` varchar(33) NOT NULL DEFAULT '' COMMENT '要修改的密码',
  `CHANGENICKNAME` varchar(33) NOT NULL DEFAULT '' COMMENT '要修改的昵称',
  `DEVSTRING` varchar(128) NOT NULL DEFAULT '' COMMENT '要关联点控的设备号',
  `CHEATREASON` varchar(128) NOT NULL DEFAULT '' COMMENT '点控原因',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;


***********************************************/

 
package models

import (
	"fmt"
	//"fmt"
	"github.com/astaxie/beego/orm"
	//"errors"
)
//记录
type UserCtrlInfo struct {
	ID int `orm:"pk;auto" ` 
	USERID int  //int(10) NOT NULL D
	NTYPE int //int(10) NOT NULL DE
	GOLD int64// bigint(20) NOT NULL 
	CHEATRATE int64//` int(20) NOT NUL
	CHEATSCORE int64//` int(20) NOT NU
	STATUS int64//` int(20) NOT NULL D
	LVSIGN int64//` int(20) NOT NULL D
	GiveGiftID int64//` bigint(20) NOT
	MailID int64//` bigint(20) NOT NUL
	DIAMOND int64//` bigint(20) NOT NU
	TICKET int64//` bigint(20) NOT NUL
	DESGAMEID int64//` int(20) NOT NUL
	CHANGEPASSWD string//` varchar(33) 
	CHANGENICKNAME string//` varchar(33
	DEVSTRING string//` varchar(128) NO
	CHEATREASON string//` varchar(128) 
	SZSIGN string 
}

//记录
type UserCtrlInfo2 struct {
	USERID int  //int(10) NOT NULL D
}

func (a *UserCtrlInfo) TableName() string {
	return TableName("UserCtrlInfo")
}


//测试 sql 语句
func  testSQLStr(sql string) ([]*UserCtrlInfo, int64){
	sql = "SELECT * FROM UserCtrlInfo"

	list2 := make([]*UserCtrlInfo, 0);
	var list []UserCtrlInfo
	var o = orm.NewOrm();
	o.Using("default")
	//query := o.QueryTable(TableName("GMAddRecord"))
	num,_ :=o.Raw(sql).QueryRows(&list);
	fmt.Println("#########################123")
	fmt.Println(list);
	return list2 ,num;
}

//获取默认值
func UserCtrlInfoGetInsert()( UserCtrlInfo ){
	 info := UserCtrlInfo{0,0,0,0,0,0,0,0,0,0,0,0,0,"","","","",""};
	
	 return info;
}

//插入值
func  UserCtrlInfoInsertValues(ras []*UserCtrlInfo) (n int, err error) {
	
	query := orm.NewOrm().QueryTable(TableName("UserCtrlInfo"))
	i, _ := query.PrepareInsert()
	for _, ra := range ras {
		_, err := i.Insert(ra)
		if err == nil {
			n = n + 1
		}
	}
	defer i.Close() // 别忘记关闭 statement
	return n, err
}

//插入值
func  UserCtrlInfoInsertValue(ras *UserCtrlInfo) ( int64, error) {
	fmt.Println(ras);
	o:= orm.NewOrm();

	query :=o.QueryTable(TableName("UserCtrlInfo"))
	i, _ := query.PrepareInsert()

	n,err := i.Insert(ras);

	
	defer i.Close() // 别忘记关闭 statement
	fmt.Println("===========UserCtrlInfoInsertValue插入数据结果========",n,err)

	return n, err
}
//'0-修改金币 1-修改作弊率 2-账号状态 3-修改用户类型(银商,普通用户)4-礼物找回 5-删除邮件 6-修改钻石 7-修改奖券 8-修改贵宾>    的推广号 9-修改密码 10-修改昵称 11-解绑手机 12-关联点控 13-修改个性签名 14-关联锁定',
//插入值
func  (ras *UserCtrlInfo)UserCtrlInfoInsertValue() ( error) {
	fmt.Println(ras);
	o:= orm.NewOrm();

	query :=o.QueryTable(TableName("UserCtrlInfo"))
	i, _ := query.PrepareInsert()

	n,err := i.Insert(ras);

	
	defer i.Close() // 别忘记关闭 statement
	fmt.Println("===========UserCtrlInfoInsertValue插入数据结果========",n,err)

	return err
}


